import Taro, { useRouter } from "@tarojs/taro";
import { View } from "@tarojs/components";

import ByButton from "@/components/ui/ByButton";
import ByEmpty from "@/components/ui/ByEmpty";
import ByIcon from "@/components/ui/ByIcon";
import ByRow from "@/components/ui/ByRow";

import useList from "@/hooks/useList";
import ApiWorkflow from "@/api/workflow";
import { TaskItem } from "@/types/global";

export default () => {
  const { params } = useRouter();

  const { loading, list } = useList<TaskItem[]>(ApiWorkflow.todos, {
    defaultParams: [
      {
        intentCustomerId: Number(params.intentCustomerId),
        status: 0,
      },
    ],
  });

  return (
    <View className="flex flex-col h-screen">
      <View className="flex-auto">
        <View className="p-8 text-center">
          <ByIcon className="text-success" name="CheckFill" size={140} />

          <View className="mt-8 font-bold text-lg">选材成功</View>
          <View className="mt-3 text-third">等待客户确认</View>
        </View>

        <View className="px-4 mt-6">
          <View className="text-second text-sm">本项目-我的其他待办</View>
          {!loading && list.length == 0 && <ByEmpty />}
        </View>
      </View>

      <View>
        <ByRow className="flex-none px-4 py-3">
          <ByButton
            size="large"
            variant="outline"
            className="flex-1 mr-3"
            onClick={() =>
              Taro.redirectTo({
                url: `/packageProject/pages/detail/index?intentCustomerId=${params.intentCustomerId}`,
              })
            }
          >
            项目界面
          </ByButton>
          <ByButton
            size="large"
            className="flex-2"
            onClick={() => Taro.switchTab({ url: "/pages/index/index" })}
          >
            回到首页
          </ByButton>
        </ByRow>
        <View className="safe-footer" />
      </View>
    </View>
  );
};
